package cn.miui.mall.controller;

import cn.miui.mall.dao.cartdao;
import cn.miui.mall.dao.imagedao;
import cn.miui.mall.pojo.shopping_cart;
import cn.miui.mall.service.impl.Cartdaoserviceimpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/Cart")
public class CartController {
    @Autowired
    private Cartdaoserviceimpl cartdao;
    @Autowired
    private imagedao imagedao;
    @RequestMapping("/findAll")
    public ModelAndView findAll(Integer id,Map<String, Object> map){
        List<shopping_cart> shoppingCartList=cartdao.findByuserid(id);
        map.put("cartList",shoppingCartList);
        map.put("imgList",imagedao.findAll());
        return new ModelAndView("gouwuche",map);
    }
    @RequestMapping("/Add")
    public boolean AddandUpdata(shopping_cart shoppingCart){
        return cartdao.addCart(shoppingCart);
    }
}
